/**
 * @param {number} 天数
 * @returns {Array}
 */

export function pickTime(days) {
  const end = new Date()
  const start = new Date()
  start.setTime(start.getTime() - 3600 * 1000 * 24 * days)
  const endTime =
   `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()} 23:59:59`
  const startTime =
  `${start.getFullYear()}-${start.getMonth() + 1}-${start.getDate()} 00:00:00`
  return [startTime, endTime]
}

export function getYearMonth(days) {
  const end = new Date()
  const start = new Date()
  start.setTime(start.getTime() - 3600 * 1000 * 24 * days)
  const endTime =
   `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`
  const startTime =
  `${start.getFullYear()}-${start.getMonth() + 1}-${start.getDate()}`
  return [startTime, endTime]
}

export function timeFormatStr(ms) {
  return (new Date(ms).getMonth() + 1) + '月' +
         new Date(ms).getDate() + '日' +
         new Date(ms).getHours() + '时' +
         new Date(ms).getMinutes() + '分' +
         new Date(ms).getSeconds() + '秒'
}

export function fullDays(ms) {
  return (
    new Date(ms).getFullYear() + '年' +
         (new Date(ms).getMonth() + 1) + '月' +
         new Date(ms).getDate() + '日' +
         new Date(ms).getHours() + '时' +
         new Date(ms).getMinutes() + '分' +
         new Date(ms).getSeconds() + '秒'
  )
}
export function getFullTime() {
  const year = new Date().getFullYear()
  const mouth = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1)
  const day = new Date().getDate()
  const hour = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()
  const minutes = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  const seconds = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  return {
    year,
    mouth,
    day,
    hour,
    minutes,
    seconds
  }
}
